package com.xdwanj.smartcity.ui.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Icon;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.xdwanj.smartcity.R;
import com.xdwanj.smartcity.data.bean.News;

import java.util.List;

public class IndexNewsAdapter extends BaseAdapter {

    Context mContext;
    List<News> news;

    public IndexNewsAdapter(Context context,List<News> news) {
        mContext = context;
        this.news = news;
    }
    @Override
    public int getCount() {
        return news.size();
    }

    @Override
    public Object getItem(int i) {
        return news.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View myView = View.inflate(mContext, R.layout.index_news_list,null);
        ImageView imageView = myView.findViewById(R.id.cover);
        Glide.with(myView.getContext()).load(news.get(i).getCover()).into(imageView);
        ((TextView) myView.findViewById(R.id.title)).setText(news.get(i).getTitle());
        return myView;
    }
}
